﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmFamilyService.h"
#include "IFamilyGeneralForm.h"


namespace gfam
{

    class IFamily2DSketchCurve;
    class IFamily2DSketchLine;
    class IFamilySketchCurve;

    ///\brief 融合体错误类型
    enum class FamilyBlendProfileErrorType : int32_t
    {
        Valid = 0,              ///< 轮廓没有错误
        NoSketch = 1,           ///< 没有草图平面
        EmptyProfile = 2,       ///< 轮廓线为空
        NotClosed = 3,          ///< 轮廓线不封闭
        MultiPolygon = 4,       ///< 轮廓线为多条polygon
        Intersect = 5,          ///< 环相交
        SelfIntersect = 6       ///< 环自交
    };

    /// \brief 融合体
    class GM_FAMILY_SERVICE_EXPORT IFamilyBlend : public IFamilyGeneralForm
    {
        DEFINE_CAST_DERIVED(gfam::IFamilyBlend, gfam::IFamilyGeneralForm)

    public:

        /// \brief 创建融合体
        /// 
        /// \param pDocument 文档
        /// \param topSketchId 顶面草图id
        /// \param bottomSketchId 底面草图id
        /// \param startOffset 起始高度
        /// \param endOffset 终止高度
        /// \return 融合体
        static IFamilyBlend* Create(gcmp::IDocument* pDocument, const gcmp::ElementId& topSketchId, const gcmp::ElementId& bottomSketchId, double startOffset = 0.0, double endOffset = 500.0);

        /// \brief 获取底面定位线
        /// 
        /// \return 底面定位线
        virtual const IFamily2DSketchLine* GetBottomLocationLine() const = 0;

        /// \brief 获取顶面定位线
        /// 
        /// \return 顶面定位线
        virtual const IFamily2DSketchLine* GetTopLocationLine() const = 0;


        ///\brief 获取顶面草图id
        /// 
        /// \return 顶面草图id
        virtual gcmp::ElementId GetTopSketchId() const = 0;


        /// \brief 设置顶面草图id
        /// 
        /// \param  id 草图id
        /// \return 设置成功返回true，失败返回false
        virtual bool SetTopSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取底面草图id
        /// 
        /// \return 底面草图id
        virtual gcmp::ElementId GetBottomSketchId() const = 0;

        /// \brief 设置底面草图id
        /// 
        /// \param  id 草图id
        /// \return 设置成功返回true，失败返回false
        virtual bool SetBottomSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取端面草图id
        /// 
        /// \return 端面草图id
        virtual gcmp::ElementId GetEndfaceSketchId() const = 0;

        /// \brief 设置端面草图id
        /// 
        /// \param  id 草图id
        /// \return 设置成功返回true，失败返回false
        virtual void SetEndfaceSketchId(const gcmp::ElementId& id) = 0;

        /// \brief 获取顶面草图
        /// 
        /// \return 顶面草图
        virtual IFamilySketch2D*  GetTopSketch() = 0;

        /// \brief 获取顶面草图
        /// 
        /// \return 顶面草图
        virtual const IFamilySketch2D*  GetTopSketch() const = 0;

        /// \brief 获取底面草图
        /// 
        /// \return 底面草图
        virtual IFamilySketch2D*  GetBottomSketch() = 0;

        /// \brief 获取底面草图
        /// 
        /// \return 底面草图
        virtual const IFamilySketch2D*  GetBottomSketch() const = 0;

        /// \brief 获取端面草图
        /// 
        /// \return 端面草图
        virtual IFamilySketch2D* GetEndfaceSketch() = 0;

        /// \brief 获取端面草图
        /// 
        /// \return 端面草图
        virtual const IFamilySketch2D* GetEndfaceSketch() const = 0;

        /// \brief 是否在编辑融合体
        /// 
        /// \return 融合体编辑状态
        virtual bool IsEditingBlend() const = 0;

        /// \brief 设置融合体是否正在编辑状态
        /// 
        /// \param  isEditingBlend 编辑状态
        virtual void SetEditingBlend(bool isEditingBlend) = 0;

        /// \brief 检查轮廓数据是否合法
        /// 
        /// \param pSketch  检查的草图
        /// \param errorCurves  出错的草图线
        /// \return 融合体错误类型
        virtual FamilyBlendProfileErrorType CheckProfileIsValid(const IFamilySketch2D* pSketch, std::vector<IFamilySketchCurve*>& errorCurves) const = 0;

        /// \brief 检查轮廓数据是否合法
        /// 
        /// \param pSketch  检查的草图
        /// \return 融合体错误类型
        virtual FamilyBlendProfileErrorType CheckProfileIsValid(const IFamilySketch2D* curSketch) const = 0;


        /// \brief 检查顶面和底面的环数是否相等
        /// 
        /// \return 相等返回true,否则返回false
        virtual bool CheckLoopsAreEqual() const = 0;

        /// \brief 获取几何是否创建成功
        /// 
        /// \return 成功返回true,否则返回false
        virtual bool GetIsCreatedSuccessfully() const = 0;


        /// \brief 设置融合体的起始高度
        /// 
        /// \param startOffset 起始高度
        /// \return 设置成功返回true,失败返回false
        virtual bool SetStartOffset(double startOffset) = 0;

        /// \brief 获取融合体的起始高度
        /// 
        /// \return 起始高度
        virtual double GetStartOffset() const = 0;

        /// \brief 设置融合体的终止高度
        /// 
        /// \param endOffset 终止高度
        /// \return 设置成功返回true,失败返回false
        virtual bool SetEndOffset(double endOffset) = 0;

        /// \brief 获取融合体的终止高度
        /// 
        /// \return 终止高度
        virtual double GetEndOffset() const = 0;

        /// \brief 融合体顶面定位线名称
        static std::wstring TopLocationLineName;

        /// \brief 融合体底面定位线名称
        static std::wstring BottomLocationLineName;

        //TODO 待确认 
        virtual void SetBottomVertexIndexPairArrayFromRevit(const std::vector<Int32>&) = 0;
        virtual void SetTopVertexIndexPairArrayFromRevit(const std::vector<Int32>&) = 0;
        virtual void SetUseVertexConnectionMapFromRevit(bool) = 0;

    };

}